/**
 * @Author YuanYuan
 * @Date 2022/5/16
 * @Time 11:39
 */
class Shape {
    //属性....

    public void draw() {
        System.out.println("画图形！");
    }
}
class Pig extends Shape{
    @Override
    public void draw() {
        System.out.println("🐖");
    }
}
class Dog extends Shape{
    @Override
    public void draw() {
        System.out.println("🐕");
    }
}
class Bird extends Shape{
    @Override
    public void draw() {
        System.out.println("🐦");
    }
}
class Duck extends Shape{
    @Override
    public void draw() {
        System.out.println("🦆");
    }
}
class Tiger extends Shape{
    @Override
    public void draw() {
        System.out.println("🐅");
    }
}
public class Test {
    public static void drawMap2( ) {
        //猪 狗 鸟 鸭子 猪
        Pig pig = new Pig();
        Dog dog = new Dog();
        Bird bird = new Bird();
        Duck duck = new Duck();

        String[] shapes = {"pig", "dog", "bird", "duck", "pig"};

        for (String shape : shapes) {
            if (shape.equals("pig")) {
                pig.draw();
            } else if (shape.equals("dog")) {
                dog.draw();
            } else if (shape.equals("bird")) {
                bird.draw();
            }else if(shape.equals("duck")) {
                duck.draw();
            }
        }
    }

    public static void drawMap3( ) {
        //猪 狗 鸟 鸭子 猪
        Pig pig = new Pig();
        Dog dog = new Dog();
        Bird bird = new Bird();
        Duck duck = new Duck();

        Shape[] shapes = {pig, dog, bird, duck, pig};

        for (Shape shape : shapes) {
            //当前shape引用的对象重写draw方法就调用，没有就调用Shape自己的
            shape.draw();
        }
    }

    public static void main(String[] args) {
        drawMap2();
    }

    public static void drawMap(Shape shape) {
        shape.draw();
    }

}
